package com.iqiyi.controller;

import com.iqiyi.dto.ActionResult;
import com.iqiyi.po.Video;
import com.iqiyi.service.GerenService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/Video")
@Slf4j
public class GerenController {
    @Autowired(required = false)
    GerenService gerenService;
    @RequestMapping(value = "/findByVideoid" , method = RequestMethod.GET)
    public ActionResult findByVideoid(Integer id){
        Video video =gerenService.findByVideoid(id);
        if (video!=null){
            return new ActionResult(200,"查询成功",video);
        }
        return new ActionResult(201,"查询失败",null);
    }
    @RequestMapping(value = "/findAllVideo" , method = RequestMethod.GET)
    public ActionResult findAllVideo(Video video){
        List<Video> videos = gerenService.findAllVideo(video);
        if (videos!=null){
            return new ActionResult(200,"查询成功",videos);
        }
        return new ActionResult(201,"查询失败",null);
    }
    @RequestMapping(value = "/insertVideo" , method = RequestMethod.POST)
    public int insertVideo(@RequestBody Video video){
        return gerenService.insertVideo(video);

    }
}
